home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
filutil
/
mdf130.zip
/
MDFL130.ZIP
/
MDFL_ENG.DOC
< prev
next >
Wrap
Text File
|
1995-01-12
|
8KB
|
286 lines
MDFLIB
Version 1.3
(C) 1994/95 Maurizio Giunti
C++ library to apply *.MDF patch files produced with a REGISTERED copy of
MDIFF/MDIFF2. Both Dos and OS/2 32bits versions. MDFLIB is totally free
of charge, and royalty free.
MDFLIB can be freely distributed at no cost, except for eventual copy
and/or shipping expensee. It is imperative anyway that the ORIGINAL
PACKET is distributed without any modification WHATSOEVER.
WARNING:
MDFLIB will work ONLY on *.MDF files produced with a REGISTERED copy of
MDIFF/MDIFF2.
0.INDEX
0.INDEX 2
1.USE CONDITIONS 3
2.C++ 3
2.1.MPatch CLASS 3
2.2.ERROR TABLE 3
2.3.READING THE HEADER 4
3.C 4
3.1.READING THE HEADER 4
3.2.APPLY THE PATCH 5
4.VISUAL BASIC 5
5.AUTHOR'S ADDRESS 5
2
1.USE CONDITIONS
Libraries cointained in this packet are fully functional only with *.MDF
files produced with a REGISTERED copy of MDIFF, so you can use them
freely. Moreover you can distribute the file MDFDLL.DLL if you need.
No fee is required, these libraries are totally royalty free.
2.C++
2.1.MPatch CLASS
To use this class is not important to know how it operates or what it
contains; but is very important to understand how its public members
operate.
MPatch()
MPatch() is the class constructor. Its function is to initialize private
data.
void SetRate(short r)
SetRate() changes the frequency of calling of Show().
short MDFPatch(char *dif, char *old, char *new)
This is the main function. Its parameters are the name of .MDF file, the
name of the file to patch and the name of the file it must create.
Warning: old and new must not contain equal strings. If old and new are
empty strings ("\0") MDFPatch() will use the names contained in the .MDF
file. The function must return 0 or, in case of error a non-0 value.
Please, see later for details.
char *LastError()
If there were errors in using MDFPatch() function, LastError() will
return a pointer to a string that explain the error.
void Show_start()
void Show()
void Show_end()
These 3 functions are useful to show messages during patch application.
Show_start() will be automatically called from MDFPatch() before it
starts applying the patch. In the same way, Show_end() will be called at
the end of the process. Show() is called during the process at a
frequency dependent from the value setted with SetRate().These 3
functions are virtual, so you must inherit MPatch class to change them.
See the SAMPLE.CPP for more details.
2.2.ERROR TABLE
MDFPatch() returns values are defined as follows:
Code Description
0 "OK!"
1 "Out of memory !"
2 "Can't open MDF file !"
3 "Invalid MDF file !"
3
4 "MDF file version mismatch !"
5 "UNREGISTERED !"
6 "Bad or incorrect OLD file !"
7 "Can't open OLD file !"
8 "Can't create NEW file !"
9 "General failure: NEW file corrupted !"
10 "OLD and NEW can't be the same file !"
2.3.READING THE HEADER
The function used to read the header of a *.MDF file is the same for C
and C++, so I'll explain it in chapter 3.1.
3.C
3.1.READING THE HEADER
Each *.MDF file contains a header in wich are recorded some useful
information. We can read this header using the readMDFhead() funcion:
short readMDFhead(char *fn, struct MDF_header_info *hi)
fn argument is a pointer to the *.MDF file name, and hi is a pointer to
the structure where the function will store the information read, and it
is defined as:
struct MDF_header_info {
char alg_ver[4];
char oldfilename[255];
char newfilename[255];
char registeredto[255];
char comment[2048];
unsigned long oldfilecrc;
short chunk_len;
unsigned long n_chunks;
};
Where:
alg_ver Version of the algorithm used to create the
*.MDF file
oldfilename OLD file original name
newfilename NEW file original name
registeredto Owner's name of the the *.MDF file (registered
only)
comment Comment
oldfilecrc OLD file crc
chunk_len Chunk lenght
n_chunks Number of chunks
Return value:
0 File not found
1 OK
-1 This is not a valid *.MDF file
-2 Incorrect version
4
3.2.APPLY THE PATCH
To apply a *.MDF file you must call the MDFPatch() function:
short MDFPatch(char *mfl,char *ofl,char *nfl)
Arguments are, in the order, the names of MDF, OLD and NEW file.
Function's return value follows the table of the chapter 3.2.
To have a short explanation of the error occourred you can use the
MDFError() function:
char *MDFError(short e)
The e argument is the number of the error.
4.VISUAL BASIC
You can use the Windows' DLL in VisualBasic but first of all you have to
declare it in a global module:
Declare Function MPATCH Lib "mdfdll.dll" Alias "@MPATCH$qnzct1t1" (ByVal
m As String, ByVal o As String, ByVal n As String) As Integer
Now you can call the function in a specified event:
r% = MPATCH(fmdf$, fold$, fnew$)
The arguments are, in the order, the names of MDF, OLD and NEW file.
Function's return value follows the table of chapter 2.2.
Warning: MDFDLL.DLL must be in the path or in the same directory of your
program!
5.AUTHOR'S ADDRESS
For any question you can contact me at:
My home address:
Maurizio Giunti
Via G.B. Foggini, 24
50142 Firenze
Italy
My E-Mail address:
Fidonet: 2:332/102.3
Internet: giunti@stat.ds.unifi.it
5